<?php
namespace Home\Controller;
use Think\Controller;
class OrderController extends CommonController {
    public function index(){
        if(I('id')){
            $res_account = D('account') -> getAccountInfo(array('account_id'=>I('id')));
            if ($res_account){
                $cond['ecm_order.pay_time'] = array('between',array($res_account['start_time'],$res_account['end_time']));
            }
        }
        $cond['ecm_order.seller_id'] = $_SESSION['seller']['user_id'];
        $cond['ecm_order.status'] = array('not in','0,11,50');
        $con = array(
            'condition' => $cond,
            'field' => 'ecm_order.* ,ecm_order_goods.specification, ecm_order_goods.goods_name',
            'order' => 'order_id desc'
        );
        //
        $count = D('order')->getOrderList($con);// 查询满足要求的总记录数
        $page = I('p') ? I('p') : '1';
        $pageSize = I('pageSize') ? I('pageSize') : '15';
        //

        $con = array(
            'condition' => $cond,
            'field' => 'ecm_order.* ,ecm_order_goods.specification, ecm_order_goods.goods_name',
            'page' => $page.','.$pageSize,
            'order' => 'order_id desc'
        );
        $res = D('order')->getOrderList($con);
        $this->assign('order',$res);
        $Page       = new \Think\Page(count($count),$pageSize);// 实例化分页类 传入总记录数和每页显示的记录数
        $Page->setConfig('header','条留言');

        $Page->setConfig('first','首页');

        $Page->setConfig('prev','上一页');

        $Page->setConfig('next','下一页');

        $Page->setConfig('last','尾页');

        $Page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%<p id="pageTips">第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pageSize.' 条/页 共 %TOTAL_ROW% 条信息)</p>');
        $show       = $Page->show();// 分页显示输出
        $this->assign('page',$show);// 赋值分页输出
        $this->display();
    }
}